﻿/**
 *	html/pem_data_protocal.js
 *
 *	(C) 2014 Yuanjj
 *
 * 	history:
 * 		2014-08-12		create the file
 */

/**
 *	init protocal
 */
function init_protocal()
{
    _create_protocal();
}

/**
 *	create the protocal option store
 */
var g_protocal;
function _create_protocal()
{
    Ext.define
    ( "model_protocal_option", {
         extend:"Ext.data.Model",
         fields:[
             {name:"serial",		type:"int"},
             {name:"pto_name", 		type:"string"},		// key word
             {name:"pto_file", 		type:"string"},
             {name:"tunnel_type", 	type:"string"},
             {name:"dev_probe", 	type:"string"},
             {name:"remark", 		type:"string"},
             {name:"used", 			type:"int"}         // -1:not install, 0:install, >0:used by device
         ],
         proxy:"memory"
    });

    g_protocal = new Ext.data.ArrayStore
    ({
         autoLoad:true,
         model:"model_protocal_option",
         /*
         data:[
             ["0","RAS848","I/O","st-1250","input output", "", 0],
             ["1","open","I/O","st-1250","input output", "??", 0],
             ["2","close","tt","st-1250","input output", "??", 0]
         ]
         */
    });
}

/**
 *	callback for setting protocal
 */
function callback_set_protocal( serial, pto_name, pto_file, tunnel_type, dev_type, remark, used )
{
    var	index 	= g_protocal.count();
    var record	= g_device_type.findRecord( "type", dev_type );

    if ( null === record )
        return;

    g_protocal.insert( index, [[serial, pto_name, pto_file, tunnel_type, record.get( "probe" ), remark, used]] );
}
